package com.aurora.oa.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.aurora.oa.R;

/**
 * Created by Administrator on 2017/3/23 0023.
 */
public class BaseActivity extends AppCompatActivity{

   /* @AnimationRes(R.anim.rotate)
    Animation animationRotate;

    @DrawableRes(R.drawable.myphoto)
    Drawable myphoto;

    @ColorRes(R.color.love)
    Integer mycolor;

    @TextRes(R.string.textres)
    CharSequence text;*/

    //获取系统service的方法(取代原来的clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);)
/*    @SystemService
    ClipboardManager clipboardManager;*/
    LinearLayout ll_base;
/*    @ViewById(R.id.ceshi)
    TextView textView;*/
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base_layout);


    }

/*    @AfterViews
    public void  init(){
        textView.setText("sadsdsadww");

    }*/
    public void setMyContentView(int layoutID){
        View view = LayoutInflater.from(this).inflate(layoutID,null);
        ll_base = (LinearLayout)  findViewById(R.id.ll_base);
        ll_base.addView(view);
    }

    public void initTitlebar(boolean isTitleVisible,String title,boolean isBackVisible){
        if(!isTitleVisible){
           LinearLayout ll_head = (LinearLayout) findViewById(R.id.ll_head);
            ll_head.setVisibility(View.GONE);
            return;
        }else{
            Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
            ActionBar ab =getSupportActionBar();
            //把原始标题置空，显示自己的居中标题
            ab.setTitle("");
            TextView tv_head_title = (TextView) findViewById(R.id.tv_head_title);
            tv_head_title.setText(title);
            ab.setDisplayHomeAsUpEnabled(isBackVisible);
            toolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    setResult();
                    finish();
                }
            });

        }
    }

    protected void setResult() {
    }

   /* @Click({R.id.button5,R.id.button6,R.id.button7})
    public void animationButtonOnClicked(View view){
        switch (view.getId()){
            case R.id.button5:{
                imageView.startAnimation(animationRotate);
            }
            break;
            case R.id.button6:{
                imageView.setImageDrawable(myphoto);
            }
            break;
            case R.id.button7:{
                Toast.makeText(getApplicationContext(),text.toString(),Toast.LENGTH_SHORT).show();
            }
            break;
        }
    }*/

/*    @LongClick({R.id.button2})
    public void buttonOnLongClicked(View view){
        switch (view.getId()){
            case R.id.button1:{
                textView.setText("Button1 is LongClicked!");//由于没注册，所以不可能被触发
            }
            break;
            case R.id.button2:{
                textView.setText("Button2 is LongClicked!");//可触发
            }
            break;
        }
    }*/

    //==============================================关于线程的注解================================================
    //相当于一个新的任务AsyncTask或者新线程Thread
   /* @Background
    public void progressBarWorks(){
        //相当于一个新的线程中执行: @Background
        int i = 1;
        while (i <= 10){
            Log.e("progress","进度: " + i);
            try {
                Thread.sleep(1000);
                updateProgressBar(i);
                //直接progressBar.setProgress(i);也可以的，所以@Background注解内部可能实现了handler机制
                i++;
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

    //指代UI线程
    @UiThread
    public void updateProgressBar(int i){
        progressBar.setProgress(i);
        if (i == 10){
            Toast.makeText(getApplicationContext(), "滚动条结束",Toast.LENGTH_SHORT).show();
        }
    }*/
}
